// pages/empty.js
const app=getApp()
Page({

  /**
   * Page initial data
   */
  data: {

  },
  //add a room
  newRoom(){
    wx.navigateTo({
      url: '/pages/newRoom/newRoom',
    })
  },

  /**
   * Lifecycle function--Called when page load
   */
  onLoad(options) {
    var roomList;
    //get the roomlist
    wx.request({
      url: app.globalData.url,
      method:'GET',
      success:(res)=>{
        this.setData({
          roomList:res.data
        })
    //get the length of roomList
    if(this.data.roomList.length!=0){
      wx.switchTab({
        url: '/pages/index/index',
      })
    //get the avatar
    var userAvatar=wx.getStorageSync('userAvatar')
    this.setData({
      userAvatar:userAvatar
    })
    }
      }
    })

  },

  /**
   * Lifecycle function--Called when page is initially rendered
   */
  onReady() {

  },

  /**
   * Lifecycle function--Called when page show
   */
  onShow() {

  },

  /**
   * Lifecycle function--Called when page hide
   */
  onHide() {

  },

  /**
   * Lifecycle function--Called when page unload
   */
  onUnload() {

  },

  /**
   * Page event handler function--Called when user drop down
   */
  onPullDownRefresh() {

  },

  /**
   * Called when page reach bottom
   */
  onReachBottom() {

  },

  /**
   * Called when user click on the top right corner to share
   */
  onShareAppMessage() {

  }
})